package com.free.front.controller.product;

import com.alibaba.fastjson.JSON;
import com.deco.domain.vo.product.DicVehicleVo;
import com.deco.domain.vo.product.PartGroupVo;
import com.free.common.vo.ResultModel;
import com.free.front.bf.product.ProductSearchBf;
import com.free.front.controller.BaseController;
import com.free.front.util.Mu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 功能概述:
 * </p>
 * <p>
 * 功能详述:
 * </p>
 */
@Controller
public class ProductSearchController extends BaseController {
    /*========================================================================*
     *                         Public Fields (公共属性)
     *========================================================================*/

    /*========================================================================*
     *                         Private Fields (私有属性)
     *========================================================================*/

    @Autowired
    private ProductSearchBf searchBf;
    /*========================================================================*
     *                         Construct Methods (构造方法)
     *========================================================================*/

    /*========================================================================*
     *                         Public Methods (公有方法)
     *========================================================================*/




    @RequestMapping(value="/getPartNumber1.json")
    @ResponseBody
    public ResultModel getPartNumber1(DicVehicleVo vo){
        return ResultModel.success(searchBf.getPartNumber3(vo));
    }


    @RequestMapping(value="/getPartNumber3.json")
    @ResponseBody
    public ResultModel getPartNumber3(DicVehicleVo vo){
        return ResultModel.success(searchBf.getPartNumber3(vo));
    }




    // ----------------- 按零件检索 ------------------- //

    @RequestMapping(value="/queryPartNumberList.json")
    @ResponseBody
    public List<String> queryPartNumberList(){
        return searchBf.queryPartNumberList();
    }

    @RequestMapping(value="/getPartNumber.json")
    @ResponseBody
    public ResultModel getPartNumber(DicVehicleVo vo){
        return ResultModel.success(searchBf.getPartNumber(vo));
    }

    // ----------------- 按零件检索 ------------------- //
    // ----------------- 按车型检索 ------------------- //
    /**
     * 按品牌
     * @return
     */
    @RequestMapping(value="/queryBrandList.json")
    @ResponseBody
    public ResultModel queryBrandList(){
        return ResultModel.success(searchBf.queryBrandList());
    }

    @RequestMapping(value="/getProdType.json")
    @ResponseBody
    public ResultModel getProdType(DicVehicleVo vo){
        return ResultModel.success(searchBf.getProdType(vo));
    }

    @RequestMapping(value="/getProdDis.json")
    @ResponseBody
    public ResultModel getProdDis(DicVehicleVo vo){
        return ResultModel.success(searchBf.getProdDis(vo));
    }

    /**
     * 根据汽车品牌,车型，排量查详细车型
     *
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getProDdet.json")
    public ResultModel proddetLabel(HttpServletRequest request, DicVehicleVo vehicleVo) {
        return ResultModel.success(searchBf.getProDdet(vehicleVo));
    }

    @ResponseBody
    @RequestMapping(value = "/getPartDet.json")
    public ResultModel getPartDet(DicVehicleVo vehicleVo){
        return ResultModel.success(searchBf.getPartDet(vehicleVo));
    }

    @ResponseBody
    @RequestMapping(value = "/mgetPartDet.json")
    public ResultModel mgetPartDet(DicVehicleVo vehicleVo){
        return ResultModel.success(searchBf.mgetPartDet(vehicleVo));
    }

    // 化学品查询
    @RequestMapping(value="/prodTeamList1.json")
    @ResponseBody
    public ResultModel prodTeamList1(PartGroupVo partGroup, HttpServletRequest request){
        String ip = Mu.getIP(request);
        return ResultModel.success(searchBf.prodTeamList1(partGroup, ip,"PC端")) ;
    }

    // 化学品查询
    @RequestMapping(value="/mprodTeamList1.json")
    @ResponseBody
    public ResultModel mprodTeamList1(PartGroupVo partGroup, String vehicleNo, HttpServletRequest request){
        String ip = Mu.getIP(request);
        return ResultModel.success(searchBf.mgettyreList(partGroup, vehicleNo, ip,"手机端")) ;
    }

    @RequestMapping(value="/mprodLtTeamList1.json")
    @ResponseBody
    public ResultModel mprodLtTeamList1(String vehicleNo, HttpServletRequest request){
        String ip = Mu.getIP(request);
        return ResultModel.success(searchBf.mprodLtTeamList1(vehicleNo)) ;
    }

    // 产品数据
    @RequestMapping(value="/gettyreList.json")
    @ResponseBody
    public ResultModel gettyreList(DicVehicleVo vo){
        return ResultModel.success(searchBf.gettyreList(vo));
    }

    //轮胎数据
    @RequestMapping(value="/tyreList.json")
    @ResponseBody
    public ResultModel tyreList(DicVehicleVo vo){
        return ResultModel.success(searchBf.tyreList(vo));
    }
    // ----------------- 按车型检索 ------------------- //

    // 产品信息查询
    @RequestMapping(value="/getPartNumber2.json")
    @ResponseBody
    public ResultModel getPartNumber2(DicVehicleVo vo){
        return ResultModel.success(searchBf.getPartNumber(vo));
    }

    // 产品组查询
    @RequestMapping(value="/getCd.json")
    @ResponseBody
    public ResultModel getCd(){
        return ResultModel.success(searchBf.getCd());
    }

    // 产品组查询(MD)
    @RequestMapping(value="/getMdCd.json")
    @ResponseBody
    public ResultModel getMdCd() {return ResultModel.success(searchBf.getMdCd());}

    @RequestMapping(value="/getPartInfo.json")
    @ResponseBody
    public ResultModel getPartInfo(PartGroupVo partGroup, HttpServletRequest request){
        String ip = Mu.getIP(request);
        return ResultModel.success(searchBf.getPartInfo(partGroup, ip,"手机端")) ;
    }

    @RequestMapping(value="/getByVehicleNo.json")
    @ResponseBody
    public ResultModel getByVehicleNo(DicVehicleVo vo){
        return  ResultModel.success(searchBf.getPartNumber3(vo));
    }
    /*========================================================================*
     *                         Private Methods (私有方法)
     *========================================================================*/
}
